<template>
  <div>
    <div id="building"></div>
    <div class="fly">
      <van-form @submit="onSubmit">
        <van-field
          v-model="phone"
          name="用户名"
          label="用户名"
          placeholder="用户名"
          :rules="[{ required: true, message: '请填写注册手机号' }]"
        />
        <van-field
          v-model="u_pwd"
          type="password"
          name="密码"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
        />
        <div style="margin: 16px">
          <van-button round block type="info" native-type="submit"
            >点击登录</van-button
          >
        </div>
      </van-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      phone: "",
      u_pwd: "",
    };
  },
  methods: {
    onSubmit(values) {
      const {phone,u_pwd}=this
      const url = '/v1/users/login'
      const params=`phone=${phone}&u_pwd=${u_pwd}`
      this.axios.post(url,params).then(res=>{
        console.log(res);
        if(res.data.code==200){
          console.log('登录成功');
          this.$router.push('/')
        }else{
          console.log('登录失败');
        }
      })

    },
  },
};
</script>

<style scoped>
#building {
  background: url("../assets/images/loginimg.png") center;
  opacity: 0.7;
  width: 100%;
  height: 100%;
}

.fly {
  position: absolute;
  left: 30px;
  bottom: 100px;
  z-index: 100;
}
div/deep/.van-cell {
  background-color: transparent !important;
  border: 1px solid #fff8f8;
  margin-top: 20px;
  border-radius: 30px;
  width: 90%;
  height: 60px;
}
.van-cell::after {
  border-bottom: 0 solid #000;
}
div/deep/.van-field__body input {
  transform: translateY(6px) !important;
  color: #fff;
  font-size: 16px;
}
div/deep/.van-field__error-message {
  transform: translateY(3px);
}

div/deep/.van-field__label {
  font-size: 16px;
  color: #fff;
  line-height: 36px;
  text-align: center;
}
.van-button--info {
  width: 100%;
  transform: translateX(-18px);
  color: #fff;
  font-size: 16px;
  background-color: #e81964;
  border: 1px solid #e81964;
}
</style>
